package org.geo.common.exception.handler;

import org.geo.common.log.Log;
import org.geo.common.response.Responser;
import org.geo.common.response.model.JsonResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * Exception的默认处理器
 *
 * @author ljy
 */
@ControllerAdvice
@RestController
public class DefaultExceptionHandlerImpl implements IExceptionHandler {
    @Override
    @ExceptionHandler(Exception.class)
    public JsonResponse handleException(Exception e) {
        String traceId = Log.getTraceId();
        Log.e(e, false, traceId);
        return Responser.serverError("服务器异常 " + traceId);
    }
}
